package com.stu.java8.stream;

import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhuzi
 */
public class StreamDubDemo {
	@Test
	public void stream() {
		ArrayList<String> list = Lists.newArrayList();
		for (int i = 0; i < 10; i++) {
			list.add(RandomStringUtils.randomAlphabetic(5));
		}

		List<String> a = list.stream().filter(e -> e.contains("a"))
				.filter(e -> e.length() > 3)
				.collect(Collectors.toList());
		System.out.println(a);
	}

	@Test
	public void debug() {
		int a = 2;
		int b = 1;
		int c = add(a, b);
		System.out.println(c);
	}

	private int add(int a, int b) {
		System.out.println("a=" + a);
		System.out.println("b=" + b);
		System.out.println("StreamDubDemo.add");
		System.out.println("StreamDubDemo.add");
		System.out.println("StreamDubDemo.add");
		System.out.println("StreamDubDemo.add");
		System.out.println("StreamDubDemo.add");
		System.out.println("StreamDubDemo.add");
		System.out.println("StreamDubDemo.add");
		System.out.println("StreamDubDemo.add");
		return a + b;
	}
}
